a = 3
import random
for x in xrange(a*4):
	print "m"+str(x)
for x in xrange(a*3):
	print "midlle(m"+str(x)+")"
for x in xrange(a*2):
	print "big(m"+str(x)+")"
for x in xrange(a):
	print "capital(m"+str(x)+")"
for x in xrange(a*4):
   for y in xrange(a*4):
	if random.randint(0,1) == 1:
		print "r(m"+str(x)+",m"+str(y)+")"

for x in xrange(a*4):
   for y in xrange(a*4):
	if random.randint(0,2) == 1:
		print "l(m"+str(x)+",m"+str(y)+")"

for x in xrange(a*4):
   for y in xrange(a*4):
	if random.randint(0,3) == 1:
		print "s(m"+str(x)+",m"+str(y)+")"




rules='''pl(X,Y) :- pl(X,Z) && pl(Z,Y)
pl(X,Y) :- l(X,Y)
ps(X,Y) :- ps(X,Z) && ps(Z,Y)
ps(X,Y) :- s(X,Y)
pd(X,Y) :- pd(X,Z) && pd(Z,Y)
pd(X,Y) :- d(X,Y)
p(X,Y)  :- pd(X,Y) || pl(X,Y) || ps(X,Y)
capital(X) -> big(X)
big(X) -> middle(X)
continent(X,Y) :- pd(X,Y)
capital(X) && capital(Y) => pl(X,Y)
~continent(X,Y) && big(X) && big(Y) => pl(X,Y) || ps(X,Y)
'''

print rules
